<template>
    <div>
        <div v-show="active==1">
            <span style="margin-left: 650px;font-size: 30px">安全日志</span>
            <el-divider content-position="right"></el-divider>
            <div style="width: 1300px">
                <span style="font-size:20px;color: red">基本信息</span>
                <el-form label-width="200px" :model="InvoiceOpenInfo">
                    <el-container>
                        <el-form-item label="发票编号：">
                            <el-input :disabled="true" v-model="InvoiceOpenInfo.id" placeholder="保存后自动生成" style="width: 500px;"></el-input>
                        </el-form-item>
                        <el-input type="hidden" v-model="InvoiceOpenInfo.pId"></el-input>
                        <el-form-item label="项目名称：">
                                <el-input :disabled="disable" v-model="InvoiceOpenInfo.pname" @focus="pid" clearable style="width: 500px;"></el-input>
                        </el-form-item>
                    </el-container> <el-container>
                    <el-input type="hidden" v-model="InvoiceOpenInfo.cId"></el-input>
                    <el-form-item label="合同名称：">
                            <el-input :disabled="disable" v-model="InvoiceOpenInfo.cname" @focus="contractname" clearable style="width: 500px;"></el-input>
                    </el-form-item>
                    <el-form-item label="收票单位：">
                        <el-select :disabled="disable" style="width: 500px;" v-model="InvoiceOpenInfo.receiveCompanyId" placeholder="收票单位">
                            <el-option value="" label="收票单位"></el-option>
                            <el-option
                                    :key="receiveCompany.id"
                                    v-for="receiveCompany in receiveCompanys"
                                    :value="receiveCompany.id"
                                    :label="receiveCompany.receiveCompanyName"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                </el-container>
                    <el-container>
                        <el-form-item label="开票单位：">
                            <el-select :disabled="disable" style="width: 500px;" v-model="InvoiceOpenInfo.openCompanyId">
                                <el-option value="" label="开票类型"></el-option>
                                <el-option
                                        :key="openCompany.id"
                                        v-for="openCompany in openCompanys"
                                        :value="openCompany.id"
                                        :label="openCompany.openCompanyName"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="发票类型：">
                            <el-select :disabled="disable"  style="width: 500px;" v-model="InvoiceOpenInfo.invoiceType" placeholder="发票类型">
                                <el-option label="==请选择==" value=""></el-option>
                                <el-option label="增值税专用发票" value="增值税专用发票"></el-option>
                                <el-option label="普通发票" value="普通发票"></el-option>
                                <el-option label="收据" value="收据"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-container>
                    <el-container>
                        <el-form-item label="发票号码：">
                            <el-input v-model="InvoiceOpenInfo.invoiceNo" :disabled="disable" style="width: 500px;"></el-input>
                        </el-form-item>
                        <el-form-item label="发票金额：">
                            <el-input-number controls-position="right" v-model="InvoiceOpenInfo.invoiceAmount" :disabled="disable" style="width: 500px;"></el-input-number>
                        </el-form-item>
                    </el-container>
                    <el-container>
                        <el-form-item label="开户银行：">
                            <el-select :disabled="disable"  style="width: 500px;" v-model="InvoiceOpenInfo.accountBank" placeholder="发票类型">
                                <el-option label="==选择==" value=""></el-option>
                                <el-option label="中国银行" value="中国银行"></el-option>
                                <el-option label="招商银行" value="中国银行"></el-option>
                                <el-option label="工商银行" value="工商银行"></el-option>
                                <el-option label="农业银行" value="农业银行"></el-option>
                                <el-option label="邮政银行" value="邮政银行"></el-option>
                            </el-select>                </el-form-item>
                        <el-form-item label="账号：">
                            <el-input v-model="InvoiceOpenInfo.accountNum" :disabled="disable"  style="width: 500px;"></el-input>
                        </el-form-item>
                    </el-container>
                    <el-container>
                        <el-form-item label="纳税人识别号：">
                            <el-input v-model="InvoiceOpenInfo.taxplayerNo" :disabled="disable" style="width: 500px;"></el-input>
                        </el-form-item>
                        <el-form-item label="电话、地址：">
                            <el-input v-model="InvoiceOpenInfo.phoneAddress" :disabled="disable" style="width: 500px;"></el-input>
                        </el-form-item>
                    </el-container>
                    <el-container>
                        <el-form-item label="填报人：">
                            <el-input v-model="InvoiceOpenInfo.editer" :disabled="true" style="width: 500px;"></el-input>
                        </el-form-item>
                        <el-form-item label="日期：">
                            <el-input type="date" v-model="InvoiceOpenInfo.openDate" :disabled="disable" style="width: 500px;"></el-input>
                        </el-form-item>
                    </el-container>
                    <el-form-item label="审批状态：">
                        <el-select :disabled="disable"  style="width: 500px;" v-model="InvoiceOpenInfo.comment" placeholder="审批状态">
                            <el-option label="==全部==" value=""></el-option>
                            <el-option label="审批中" value="审批中"></el-option>
                            <el-option label="未提交" value="未提交"></el-option>
                            <el-option label="审批通过" value="审批通过"></el-option>
                            <el-option label="审批不通过" value="审批不通过"></el-option>
                            <el-option label="作废" value="作废"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-input type="hidden" v-model="InvoiceOpenInfo.attachIds" style="width: 500px;"></el-input>
                    <multi-file-upload style="font-size:20px;color: red"
                                       title="附件"
                                       action="http://localhost/uploads"
                                       :params="{folder: 'InvoiceOpenInfoSrvice'}"
                                       :headers="{token: token}"
                                       :show-button="!checkRoute"
                                       @uploadSuccess="handleUploadSuccess"
                                       :parent-file-list="fileList"
                    ></multi-file-upload>

                </el-form>
                <el-container>
                <el-button type="primary"  @click="consle">取消</el-button>
                <el-button type="primary" :disabled="disable" @click="AddOpenCompan">确认提交</el-button>
                </el-container>

            </div>

        </div>
        <!--所属项目子组件-->
        <el-dialog :visible.sync="dialogVisible" width="50%">
            <project-info-list v-if="dialogVisible" @row="project"></project-info-list>
        </el-dialog>
        <!-- 合同子组件 -->
        <el-dialog  :visible.sync="dialogVisible4"  width="50%">
            <laber-contract v-if="dialogVisible4"  @row="LaberContract"></laber-contract>
        </el-dialog>
    </div>
</template>

<script>
    import {OpenCompanySeriver} from "../../../model/gsl/OpenCompanySeriver";
    const  open=OpenCompanySeriver.getInstance();
    import {ReceiveCompanySeriver} from "../../../model/gsl/ReceiveCompanySeriver";
    const  rece=ReceiveCompanySeriver.getInstance();
    import ProjectInfoList from "../../common/projectInfo/ProjectInfoList";
    import LaberContract from '../../common/providerinfo/LaberContract';
    export default {
        components:{ProjectInfoList,LaberContract},
        props:["InvoiceOpenInf","securitychecks","ad","disabled"],
        data() {
            return {
                active: 1,
                fileList:JSON.parse(JSON.stringify(this.securitychecks)),
                openCompanys:[],
                receiveCompanys:[],
                ads:JSON.parse(JSON.stringify(this.ad)),
                dialogVisible:false,
                dialogVisible4:false,
                disable:this.disabled,
                InvoiceOpenInfo:JSON.parse(JSON.stringify(this.InvoiceOpenInf))
            };
        },
        methods: {
            consle(){
                this.$emit("consle",this.ads=1)
            },
            //开启隐藏项目子组件
            pid() {
                this.dialogVisible = true;
            },
            //响应项目组件
            project(row) {
                this.InvoiceOpenInfo.pname = row.projectName;
                this.InvoiceOpenInfo.pId = row.id; //获取所属项目id
                this.dialogVisible = false;
            },
            //开启合同名称组件
            contractname(){
                this.dialogVisible4 = true;
            },
            //响应合同组件
            LaberContract(row){
                this.InvoiceOpenInfo.cname =row.contract_name;
                this.InvoiceOpenInfo.cId =row.id
                this.dialogVisible4 = false;
            },
            getopenCompany(){
                open.list(null).then((re)=>{
                    this.openCompanys=re.data.data;
                })
            },
            getreceiveCompanys(){
                rece.list(null).then((re)=>{
                    this.receiveCompanys=re.data.data;
                })
            },
            handleUploadSuccess(ids,item) {
                console.log(item)
                this.InvoiceOpenInfo.attachIds=ids
            },
            AddOpenCompan(){
               this.$emit("AddOpenCompan",this.InvoiceOpenInfo)
            }
        },

        created() {
            this.getopenCompany();
            this.getreceiveCompanys();
        },
        computed: {
            token: {
                get() {
                    return this.$store.state.token;
                }
            },
            checkRoute() {
                return Object.keys(this.$route.params).length != 0;
            }
        }
    };
</script>

<style>
</style>